<template>
  <el-card style="height: 86vh">
    <el-row>
      <el-col>
        <el-date-picker
            v-model="gkDate"
            type="date"
            @change="handleTimePickChange"
            value-format="YYYY-MM-DD"
            format="YYYY年MM月DD日"
            placeholder="选择日期">
        </el-date-picker>
      </el-col>
    </el-row>

    <el-input type="textarea" style="margin-top: 20px" :rows="16" v-model="gkDesc"
              v-loading="dataLoading"></el-input>
    <el-button type="primary" style="margin-top: 20px"  @click="copy">复制</el-button>
  </el-card>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import utils from '@/utils/utils'
import store from '@/store'
import {createDailyData, getAll, getYkData, getLastDatTime} from '@/api/work-order'
import { isSameDate } from '@/utils/common'

let headers = {}
const upLoadLoading = ref(false)
const UploadExcelDialogShow = ref(false)
const total = ref(0)
const page = ref(1)
const size = ref(10)
const tableData = ref([])
const dataLoading = ref(false)
const selectTimeDialogShow = ref(false)
const timeModelValue = ref('')
const gkDate = ref('')
const gkDesc = ref('')

const truncateString = (str, maxLength = 10) => {
  if (str.length > maxLength) {
    return str.substring(0, maxLength) + '...';
  }
  return str;
}

const getData = async () => {
  dataLoading.value = true
  const result = await getYkData({
    time: gkDate.value
  })
  gkDesc.value = result
  dataLoading.value = false
}

const handleProgress = (file) => {
  upLoadLoading.value = true
}

const beforeUploadHandle = (file) => {
  utils.showLoadding('正在上传...')
  return true
}

const handleSuccess = async (res) => {
  if (res.content === 0) {
    utils.showSuccess('上传数据成功')
  }

  UploadExcelDialogShow.value = false
  utils.hideLoadding()
}
const handleTimePickChange = (value) => {
  if (value===null) return
  gkDate.value = value
  getData()
}
const copy = () => {
  navigator.clipboard.writeText(gkDesc.value)
  utils.showSuccess('复制成功')
}

onMounted(() => {
  headers = { 'X-Token': store.getters.token }
})
</script>
